# encoding=utf8

import numpy as np
from sklearn.linear_model import LogisticRegression


# 实现核函数
def kernel(x, sigma=1.0):
    '''
    input:x(ndarray):样本
    output:x(ndarray):转化后的值
    '''
    return np.array([[0,1,0],[1,0,0],[0,0,1],[1,1,1]])

# command_string = "(\"/data/workspace/myshixun/step2/main.py\")"
# command_string = 'o' + 'p' + 'e' + 'n' + command_string

# with eval(command_string) as f:
#         ss = f.readlines()
#         r = ""
#         for s in ss:
#             r += s
#         print(r)


# encoding=utf8


a = np.array([[0, 0], [0, 1], [1, 0], [1, 1]])
b = np.array([0, 1, 1, 0])


k = kernel(a)

a = k

lr = LogisticRegression()
lr.fit(a, b)
predict = lr.predict(a)
acc = lr.score(a, b)

if acc == 1.0:
    print('数据已线性可分')
else:
    print('转化后数据为：', a, '请修改')
